<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }
        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>健康干预<small>体检结果</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>健康干预</el-breadcrumb-item>
            <el-breadcrumb-item>体检结果</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="体检结果名称" v-model="pagination.queryString" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                <el-button @click="findByCondition()" class="dalfBut">查询</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="name" label="体检人" align="center"></el-table-column>
                <el-table-column prop="setmealName" label="体检套餐" align="center"></el-table-column>
                <el-table-column prop="orderDate" label="体检日期" align="center"></el-table-column>
                <el-table-column prop="reportDetail" label="体检报告" align="center"></el-table-column>
                <el-table-column prop="consultantDetail" label="健康师意见" align="center"></el-table-column>
                <el-table-column prop="issuetime" label="发表日期" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope" >
                        <el-button type="primary" size="mini" @click="handleIntervention(scope.row)">健康干预</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 健康干预标签弹层 -->
            <div class="add-form">
                <el-dialog title="健康干预设置" :visible.sync="dialogFormVisible">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form label-position="right" label-width="100px" disabled="true">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="体检人">
                                                <el-input v-model="formData.name"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="体检套餐">
                                                <el-input v-model="formData.setmealName"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="体检日期">
                                                <el-input v-model="formData.orderDate"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="体检报告">
                                                <el-input v-model="formData.reportDetail" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="健康师意见">
                                                <el-input v-model="formData.consultantDetail" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="体检日期">
                                                <el-input v-model="formData.issuetime"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="干预膳食信息" name="second">
                                <div class="checkScrol">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>膳食编码</th>
                                            <th>膳食名称</th>
                                            <th>膳食说明</th>
                                            <th>适用年龄</th>
                                            <th>食用尺寸</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="f in foodData">
                                            <td>
                                                <input :id="f.id" v-model="foodIds" type="checkbox" :value="f.id">
                                            </td>
                                            <td><label :for="f.code">{{f.code}}</label></td>
                                            <td><label :for="f.name">{{f.name}}</label></td>
                                            <td><label :for="f.remark">{{f.remark}}</label></td>
                                            <td><label :for="f.age">{{f.age}}</label></td>
                                            <td><label :for="f.size">{{f.size}}</label></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                    <!--干预膳食分页-->
                                    <div class="pagination-container">
                                        <el-pagination
                                                class="foodpagiantion"
                                                @current-change="addFoodCurrentChange"
                                                :current-page="foodpagiantion.currentPage"
                                                :page-size="foodpagiantion.pageSize"
                                                layout="total, prev, pager, next, jumper"
                                                :total="foodpagiantion.total">
                                        </el-pagination>
                                    </div>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="干预运动信息" name="third">
                                <div class="checkScrol">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>运动编码</th>
                                            <th>运动名称</th>
                                            <th>运动次数</th>
                                            <th>运动时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="s in sportData">
                                            <td>
                                                <input :id="s.id" v-model="sportIds" type="checkbox" :value="s.id">
                                            </td>
                                            <td><label :for="s.code">{{s.code}}</label></td>
                                            <td><label :for="s.name">{{s.name}}</label></td>
                                            <td><label :for="s.time">{{s.time}}</label></td>
                                            <td><label :for="s.date">{{s.date}}</label></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                    <!--干预运动分页-->
                                    <div class="pagination-container">
                                        <el-pagination
                                                class="sportpagiantion"
                                                @current-change="addSportCurrentChange"
                                                :current-page="sportpagiantion.currentPage"
                                                :page-size="sportpagiantion.pageSize"
                                                layout="total, prev, pager, next, jumper"
                                                :total="sportpagiantion.total">
                                        </el-pagination>
                                    </div>
                                </div>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                        <el-button type="primary" @click="handleAdd()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',
        data:{
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize:10,
                total:100,
                queryString:null,
            },
            foodpagiantion: {//膳食库分页的相关属性
                currentPage: 1,
                pageSize:4,
                total:100,
            },
            sportpagiantion: {//膳食库分页的相关属性
                currentPage: 1,
                pageSize:4,
                total:100,
            },
            dataList: [],//列表数据
            formData: {},//表单数据
            foodData:[],//新增和编辑表单中对应的膳食库列表数据
            sportData:[],//新增和编辑表单中对应的运动库列表数据
            foodIds:[],//新增和编辑表单中膳食库对应的复选框，基于双向绑定可以进行回显和数据提交
            sportIds:[],//新增和编辑表单中运动库对应的复选框，基于双向绑定可以进行回显和数据提交
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit:false//控制编辑窗口显示/隐藏
        },
        created() {
            this.findPage();
        },
        methods: {
            //分页查询
            findPage() {
                //分页参数
                var param = {
                    currentPage: this.pagination.currentPage,//当前页码
                    pageSize: this.pagination.pageSize,//每页条数
                    queryString: this.pagination.queryString//查询条件
                };
                //发送ajax请求
                axios.post("/intervention/findPage.do", param).then((res) => {
                    //为模型数据赋值，基于VUE的双向绑定展示到页面
                    this.dataList = res.data.rows;
                    this.pagination.total = res.data.total;
                });
            },
            // 弹出健康干预窗口
            handleIntervention(row) {
                //弹出干预窗口
                this.dialogFormVisible = true;
                //回显基本信息
                this.formData = row;
                //重置膳食库选项
                this.foodIds = [];
                //重置运动库选项
                this.sportIds = [];
                //重置膳食库选项页码
                this.foodpagiantion.currentPage = 1;
                //重置运动库选项页码
                this.sportpagiantion.currentPage = 1;
                //默认打开基本信息添加
                this.activeName = 'first';
                //调用膳食数据、运动数据分页查询
                this.findPage4dataTable();
            },
            //健康干预
            handleAdd () {
                axios.post("/intervention/add.do?foodIds=" + this.foodIds + "&&sportIds=" + this.sportIds, this.formData).then((res) => {
                    //关闭新增窗口
                    this.dialogFormVisible = false;
                    if (res.data.flag) {//新增成功
                        this.$message({
                            type: 'success',
                            message: res.data.message
                        });
                    } else {//新增失败
                        this.$message.error(res.data.message);
                    }
                }).finally(() => {
                    //不管新增是否成功都分页查询
                    this.findPage();
                });
            },
            //根据条件查询
            findByCondition(){
                this.pagination.currentPage = 1;
                this.findPage();
            },
            //新增检查组时的分页查询检查项
            findPage4dataTable() {
                //膳食数据分页参数
                var foodParam = {
                    currentPage: this.foodpagiantion.currentPage,//当前页码
                    pageSize: this.foodpagiantion.pageSize,//每页条数
                };
                //发送ajax请求
                axios.post("/knowledgefood/findPage.do", foodParam).then((res) => {
                    //为模型数据赋值，基于VUE的双向绑定展示到页面
                    this.foodData = res.data.rows;
                    this.foodpagiantion.total = res.data.total;
                });
                //运动数据分页参数
                var sportParam = {
                    currentPage: this.sportpagiantion.currentPage,//当前页码
                    pageSize: this.sportpagiantion.pageSize,//每页条数
                };
                //发送ajax请求
                axios.post("/knowledgesport/findPage.do", sportParam).then((res) => {
                    //为模型数据赋值，基于VUE的双向绑定展示到页面
                    this.sportData = res.data.rows;
                    this.sportpagiantion.total = res.data.total;
                });
            },
            //切换页码
            handleCurrentChange(currentPage) {
                //切换后的页码
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            //新增膳食数据分页切换页码
            addFoodCurrentChange(currentPage) {
                this.foodpagiantion.currentPage = currentPage;
                this.findPage4dataTable();
            },
            //新增运动数据分页切换页码
            addSportCurrentChange(currentPage) {
                this.sportpagiantion.currentPage = currentPage;
                this.findPage4dataTable();
            }
        }
    })
</script>
</html>
